﻿using UnityEngine;
using System.Collections;

/// <summary>
/// 物品共有属性类
/// </summary>
public class BaseProperty
{
    public int ID { get; set; }
    public string name { get; set; }
    public string description { get; set; }
    public int capacity { get; set; }
    public int buyPrice { get; set; }
    public int sellPrice { get; set; }
    public string sprite { get; set; }
    public KnapsackGood.GoodType goodType { get; set; }
    public KnapsackGood.GoodQuality goodQuality { get; set; }

    public BaseProperty()
    {}

    public BaseProperty(int ID, string name, string description, int capacity, int buyPrice, int sellPrice, string sprite, KnapsackGood.GoodType goodType, KnapsackGood.GoodQuality goodQuality)
    {
        this.ID = ID;
        this.name = name;
        this.description = description;
        this.capacity=capacity;
        this.buyPrice = buyPrice;
        this.sellPrice = sellPrice;
        this.sprite = sprite;
        this.goodType = goodType;
        this.goodQuality = goodQuality;
    }
}

/// <summary>
/// 物品基类
/// </summary>
public class KnapsackGood 
{
    public BaseProperty goodProperty { get; set; }

    public KnapsackGood()
    { 
    }

    public KnapsackGood(BaseProperty goodProperty)
    {
        this.goodProperty = goodProperty;
    }

    /// <summary>
    /// 物品类型
    /// </summary>
    public enum GoodType
    {
        Consumable, //消耗品
        Equipment,  //装备
        Weapon,     //武器
        Meterial    //材料
    }

    /// <summary>
    /// 物品品质
    /// </summary>
    public enum GoodQuality
    {
        Common,     //普通
        Uncommon,   //不普通
        Rare,       //稀有
        Epic,       //史诗
        Legendary   //传奇
    }

	public virtual string GetDescribe()
	{
		string color = "";
		switch (goodProperty.goodQuality)
		{
			case KnapsackGood.GoodQuality.Common:
				color = "white";
				break;
			case KnapsackGood.GoodQuality.Epic:
				color = "lime";
				break;
			case KnapsackGood.GoodQuality.Legendary:
				color = "navy";
				break;
			case KnapsackGood.GoodQuality.Rare:
				color = "magenta";
				break;
			case KnapsackGood.GoodQuality.Uncommon:
				color = "orange";
				break;
			default:
				break;
		}

		string describe = string.Format("<color={0}>{1}</color>\n<size=10><color=green>购买价格：{2} 出售价格：{3}</color></size>\n<color=yellow><size=10>{4}</size></color>", color, goodProperty.name, goodProperty.buyPrice, goodProperty.sellPrice, goodProperty.description);

		return describe;
	}
}
